package com.dream.dao.impl;

import com.dream.dao.VisitRecordDao;
import com.dream.pojo.VisitRecord;
import com.dream.utils.DBUtil;

import java.util.List;

public class VisitRecordDaoImpl implements VisitRecordDao {
    @Override
    public int addVisitRecord(VisitRecord visitRecord) {
        try {
            DBUtil.commonUpdate("insert into visit_record values(null,?,?,?,?)",visitRecord.getStuId(),
                    visitRecord.getStuTemp(),
                    visitRecord.getDormitoryId(),
                    visitRecord.getRecordDate());
            return 1;
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
    }

    @Override
    public List<VisitRecord> findVisitRecordsByStuId(String stuId) {
        return  DBUtil.commonQuery(VisitRecord.class, "select * from visit_record where stu_id=?", stuId);
    }
}
